@extends('admin::layouts.master')
@section('title')
    添加服务类型
@endsection
@section('tab')
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form" >
                {{csrf_field()}}
                {{hi_form_hidden('pid',   $arr_search['pid']  )}}
                {{hi_form_hidden('type', $arr_search['type']  )}}
                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>名称</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入名称"></div>
                </div>


                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>店铺类型</label>
                    <div class="layui-input-block" style="width: 300px;">
                        <select name="type" @if( isset( $arr_search['type'] ) )disabled @endif >
                            <option value="">请选择店铺类型</option>
                            <option value="1" @if( isset( $arr_search['type'] ) && $arr_search['type'] == 1 ) selected="selected" @endif >维修店</option>
                            <option value="2" @if( isset( $arr_search['type'] ) && $arr_search['type'] == 2 ) selected="selected" @endif >检测站</option>
                        </select>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label for="username" class="layui-form-label">
                        <span class="x-red">*</span>排序</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="sort" lay-verify="required" autocomplete="off" class="layui-input" placeholder="请输入名称"></div>
                </div>



                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label"></label>
                    <button class="layui-btn" lay-filter="btn_add" lay-submit="">确认</button>
                </div>
            </form>
        </div>
    </div>

@endsection


@section('tab_js')
    @include('admin::activity._js')
    <script>

        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
            var is_submit = false;
            //监听提交
            form.on('submit(btn_add)', function (data) {

                if( is_submit ){
                    return false;
                }
                is_submit = true;

                $.ajax({
                    url: js_url('admin-server-type-store'),
                    type: 'post',
                    data: data.field,
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg("增加成功", {time: 500, icon: 6}, function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        } else {
                            is_submit = false;
                            layer.msg(result.msg, {time: 2000, icon: 5});
                        }
                    }
                });
                return false;

            });

        });
    </script>
@endsection